$(document).ready(function(){
				
	
			
			var upd = window.location.search;
			var reg = upd.substr(5);
			if(reg==1){
				$(".reg_h").eq(1).css("color","#FFA00A");
				$(".reg_h").eq(0).css("color","black");
				$("#register_leftcon_log").css("display","block");
				$("#register_leftcon_re").css("display","none");
			}
			
			$(".reg_h").click(function(){
				$(this).css("color","#FFA00A");
				$(this).parent().siblings().children(".reg_h").css("color","black");
			});
			$(".reg_h").each(function(index){
				$(".reg_h").eq(index).click(function(){
					$(".register_leftcon").eq(index).css("display","block");
					$(".register_leftcon").eq(index).siblings(".register_leftcon").css("display","none");
				});
			});
			$("#reg_sub_login").click(function(){
				$("#register_leftcon_log").css("display","none");
				$("#register_leftcon_cha").css("display","block");
			});
			$("#reg_sub_login").click(function(){
				$.get("UserserController?op=UpdatePwd&UserName="+$("#logname").val(),function(data,status){
					console.log(data);
					
				});
			});
			
			
			
			$("#yanzheng").click(function(){
				creatyzm();
			});
			creatyzm();
			function creatyzm() {
					var codes = [];
					//数字:48-57;unicode编码
					for(var i = 48; i < 57; codes.push(i), i++);
					/*console.log(codes);*/
					//大写字母:65-90;unicode编码
					for(var i = 65; i < 90; codes.push(i), i++);
					//小写字母:97-122;unicode编码
					for(var i = 97; i < 122; codes.push(i), i++);
					var arr = [];
					for(var i = 0; i < 4; i++) { //从0-61之间取随机数
						var index = Math.floor(Math.random() * (57 - 0 + 1) + 0);
						var char1 = String.fromCharCode(codes[index]);
						arr.push(char1);
					}
					/*console.log(arr);*/
					var code = arr.join("");
					//document.write("验证码:" + code);
					$("#yanzheng").html(code);	

				}
			
			
			
			
			//限制
		
			
			 
			$("#reg_submit").click(function(){
				var ddname = $("#ddname").val();
				var ddnameReg = /^.{4,30}$/;
				var ddzhanghao = $("#ddzhanghao").val();
				var ddzhanghaoReg = /^[a-zA-Z]{1}(\w){5,15}$/;
				var ddmima = $("#ddmima").val();
				var ddmimaReg = /^(\w){6,18}$/;
				var ddqrmima = $("#ddqrmima").val();
				$.get("UserserController?op=UserNameExit&UserName="+$(this).val(),function(data,status){
					if($("#idenCode").val().toUpperCase()!=$("#yanzheng").html().toUpperCase()){
						$("#yz").html("！验证码出错")
					}else if(!ddnameReg.exec(ddname)){
						$("#nicheng").html("！昵称不符合规范");
					}else if(!ddmimaReg.exec(ddmima)){
						$("#zhanghao").html("！账号不符合规范");
					}else if(!ddmimaReg.exec(ddmima)){
						$("#mima").html("！密码不符合规范");
					}else if(ddqrmima!=ddmima){
						$("#queren").html("！密码不相同");
					}else if(data=="账号已经存在了"){
						$("#zhanghao").html("!账号已经存在");
					}else{
						$.post("UserserController?op=Register",
						{
							MesgName:$("#ddname").val(),
							UserName:$("#ddzhanghao").val(),
							UserPass:$("#ddmima").val(),
							MesgSex:$("#ddsex").val(),
							MesgAddress:$("#ddborn").val()
						},	
						function(data,status){
							if(data=="注册成功"){
								alert(data);
								location.href="login.html";
							}else{
								alert(data);
								location.href="register.jsp"
							}
						});
					}
				});
			});		
			
			$("#ddname").blur(function(){
				var ddname = $("#ddname").val();
				var ddnameReg = /^.{4,30}$/;
				if(!ddnameReg.exec(ddname)){
					$("#nicheng").html("！昵称不符合规范");
			 		}
			 	else{
			 		$("#nicheng").html("");
				 }		 
			});
			$("#ddzhanghao").blur(function(){
				var ddzhanghao = $("#ddzhanghao").val();
				var ddzhanghaoReg = /^[a-zA-Z]{1}(\w){5,15}$/;
				$.get("UserserController?op=UserNameExit&UserName="+$(this).val(),function(data,status){
					if(data=="账号已经存在了"){
						$("#zhanghao").html("！账号已经存在");
					}else if(!ddzhanghaoReg.exec(ddzhanghao)){
						$("#zhanghao").html("！账号不符合规范");
					}else{
						$("#zhanghao").html("");
					}
				});
			});
			$("#ddmima").blur(function(){
				var ddmima = $("#ddmima").val();
				var ddmimaReg = /^(\w){6,18}$/;
				if(!ddmimaReg.exec(ddmima)){
				 	$("#mima").html("！密码不符合规范");
				 }else{
				 	$("#mima").html("");
				 }
			});
			 $("#ddqrmima").blur(function(){
				 var ddmima = $("#ddmima").val();
				 var ddqrmima = $("#ddqrmima").val();
			 	if(ddqrmima==ddmima){
			 		$("#queren").html("");
			 	}else{
			 		$("#queren").html("！密码不相同");
			 	}
			 });


		});
	